<?php

 function auth_check($auth_code,$host){
 	 return array('game'=>'pk10,xyft,ssc,bj28,jnd28,k3,k3bj,k3gx,k3jl');
}


/*
 * 竞猜格式检测
 * */
function check_format($message,$min_point,$max_point,$xz_open,$xz_max) {
	$data['error'] = 1;
	//车号大小单双(20-20,000)
	// 12345双100 = 1~5车道买双各$100 = 总$500
	//1双100
	if ($xz_open['dxds'] && preg_match('/^(?!\d*?(\d)\d*?\1)\d{1,10}+(大|双|小|单){1}+\d+$/', $message)) {
		$ex_info = explode('大', $message);
		if (count($ex_info) > 1) {
			$info = $ex_info;
		}
		$ex_info = explode('小', $message);
		if (count($ex_info) > 1) {
			$info = $ex_info;
		}
		$ex_info = explode('单', $message);
		if (count($ex_info) > 1) {
			$info = $ex_info;
		}
		$ex_info = explode('双', $message);
		if (count($ex_info) > 1) {
			$info = $ex_info;
		}
		
		// $info = explode('/', $message);
		if($info[1]>=$min_point && $info[1]<=$xz_max['dxds']){
			$data['points'] = $info[1]*strlen($info[0]);
			$data['type'] = 1;
		}else{
			if ($info[1]<$min_point) {
				$data['error'] = 0;
			} else {
				$data['error'] = 2;
			}
			$data['xz_max'] = $xz_max['dxds'];
		}
	}

	//车号大小单双(20-20,000)
	// 12345/双/100 = 1~5车道买双各$100 = 总$500
	// if ($xz_open['dxds'] && preg_match('/^(?!\d*?(\d)\d*?\1)\d{1,10}+\/{1}+(大|双|小|单){1}+\/{1}+\d+$/', $message)) {
	// 	$info = explode('/', $message);
	// 	if($info[2]>=$min_point && $info[2]<=$xz_max['dxds']){
	// 		$data['start'] = serialize(str_split($info[0]));
	// 		$data['points'] = $info[2]*strlen($info[0]);
	// 		$data['type'] = 1;
	// 	}else{
	// 		if ($info[2]<$min_point) {
	// 			$data['error'] = 0;
	// 		} else {
	// 			$data['error'] = 2;
	// 		}
	// 		$data['xz_max'] = $xz_max['dxds'];
	// 	}
	// }

	if ($xz_open['dxds'] && preg_match('/^(大|双|小|单){1}+\d+$/', $message)) {
		// $info = explode('/', $message);
		$info = substr($message, 3);
		if($info>=$min_point && $info<=$xz_max['dxds']){
			$data['points'] = $info;
			$data['type'] = 1;
		}else{
			if ($info<$min_point) {
				$data['error'] = 0;
			} else {
				$data['error'] = 2;
			}
			$data['xz_max'] = $xz_max['dxds'];
		}
	}

	//车号(20-20,000)
	// 12345/89/20 = 1~5车道的8号、9号各买$20 = 总$200
	if ($xz_open['chehao'] && preg_match('/^(?!\d*?(\d)\d*?\1)\d{1,10}+\/{1}+(?!\d*?(\d)\d*?\1)\d{1,100}+\/{1}+\d+$/', $message)) {
		$info = explode('/', $message);
		if($info[2]>=$min_point && $info[2]<=$xz_max['chehao']){
			$data['start'] = serialize(str_split($info[0]));
			$data['points'] = $info[2]*strlen($info[0])*strlen($info[1]);
			$data['type'] = 2;
		}else{
			if ($info[2]<$min_point) {
				$data['error'] = 0;
			} else {
				$data['error'] = 2;
			}
			$data['xz_max'] = $xz_max['chehao'];
		}
	}

	//3234.112.100
	if ($xz_open['chehao'] && preg_match('/^(?!\d*?(\d)\d*?\1)\d{1,10}+\.{1}+(?!\d*?(\d)\d*?\1)\d{1,100}+\.{1}+\d+$/', $message)) {
		$info = explode('.', $message);
		if($info[2]>=$min_point && $info[2]<=$xz_max['chehao']){
			$data['start'] = serialize(str_split($info[0]));
			$data['points'] = $info[2]*strlen($info[0])*strlen($info[1]);
			$data['type'] = 2;
		}else{
			if ($info[2]<$min_point) {
				$data['error'] = 0;
			} else {
				$data['error'] = 2;
			}
			$data['xz_max'] = $xz_max['chehao'];
		}
	}

	if ($xz_open['chehao'] && preg_match('/^(?!\d*?(\d)\d*?\1)\d{1,100}+\/{1}+\d+$/', $message)) {
		$info = explode('/', $message);
		if($info[1]>=$min_point && $info[1]<=$xz_max['chehao']){
			// $data['start'] = serialize(str_split($info[0]));
			$data['points'] = $info[1]*strlen($info[0]);
			$data['type'] = 2;
		}else{
			if ($info[1]<$min_point) {
				$data['error'] = 0;
			} else {
				$data['error'] = 2;
			}
			$data['xz_max'] = $xz_max['chehao'];
		}
	}

	//123.123.100
	if ($xz_open['chehao'] && preg_match('/^(?!\d*?(\d)\d*?\1)\d{1,100}+\.{1}+\d+$/', $message)) {
		$info = explode('.', $message);
		if($info[1]>=$min_point && $info[1]<=$xz_max['chehao']){
			// $data['start'] = serialize(str_split($info[0]));
			$data['points'] = $info[1]*strlen($info[0]);
			$data['type'] = 2;
		}else{
			if ($info[1]<$min_point) {
				$data['error'] = 0;
			} else {
				$data['error'] = 2;
			}
			$data['xz_max'] = $xz_max['chehao'];
		}
	}

	//组合(20-10,000)
	// 890/大单/50 = 8.9.10车道大单各买$50 = 总$150
	if ($xz_open['zuhe_1'] && preg_match('/^(?!\d*?(\d)\d*?\1)\d{1,10}+(大单|小双|小单|大双){1}+\d+$/', $message)) {
		$info = explode('/', $message);
		// if($info[2]>=$min_point && $info[2]<=$xz_max['zuhe']){
		// 	$data['start'] = serialize(str_split($info[0]));
		// 	$data['points'] = $info[2]*strlen($info[0]);
		// 	$data['type'] = 3;
		// }else{
		// 	if ($info[2]<$min_point) {
		// 		$data['error'] = 0;
		// 	} else {
		// 		$data['error'] = 2;
		// 	}
		// 	$data['xz_max'] = $xz_max['zuhe'];
		// }

		$ex_info = explode('大单', $message);
		if (count($ex_info) > 1) {
			$info = $ex_info;
		}
		$ex_info = explode('小双', $message);
		if (count($ex_info) > 1) {
			$info = $ex_info;
		}
		$ex_info = explode('小单', $message);
		if (count($ex_info) > 1) {
			$info = $ex_info;
		}
		$ex_info = explode('大双', $message);
		if (count($ex_info) > 1) {
			$info = $ex_info;
		}
		
		if($info[1]>=$min_point && $info[1]<=$xz_max['zuhe']){
			$data['points'] = $info[1]*strlen($info[0]);
			$data['type'] = 3;
		}else{
			if ($info[1]<$min_point) {
				$data['error'] = 0;
			} else {
				$data['error'] = 2;
			}
			$data['xz_max'] = $xz_max['zuhe'];
		}
	}

	//龙虎(20-20,000)
	// 123/龙/100 = 1~3车道买龙各$100=总$300
	if ($xz_open['lh'] && preg_match('/^(?![1-5]*?([1-5])[1-5]*?\1)[1-5]{1,5}+(龙|虎){1}+\d+$/', $message)) {
		$info = explode('/', $message);
		// if($info[2]>=$min_point && $info[2]<=$xz_max['lh']){
		// 	$data['start'] = serialize(str_split($info[0]));
		// 	$data['points'] = $info[2]*strlen($info[0]);
		// 	$data['type'] = 4;
		// }else{
		// 	if ($info[2]<$min_point) {
		// 		$data['error'] = 0;
		// 	} else {
		// 		$data['error'] = 2;
		// 	}
		// 	$data['xz_max'] = $xz_max['lh'];
		// }

		$ex_info = explode('龙', $message);
		if (count($ex_info) > 1) {
			$info = $ex_info;
		}

		$ex_info = explode('虎', $message);
		if (count($ex_info) > 1) {
			$info = $ex_info;
		}
		
		if($info[1]>=$min_point && $info[1]<=$xz_max['lh']){
			$data['points'] = $info[1]*strlen($info[0]);
			$data['type'] = 4;
		}else{
			if ($info[1]<$min_point) {
				$data['error'] = 0;
			} else {
				$data['error'] = 2;
			}
			$data['xz_max'] = $xz_max['lh'];
		}
	}

	//冠亚庄闲(20-20,000)
	// 庄/200 = 冠军大于亚军即中奖
	if ($xz_open['zx'] && preg_match('/^(庄|闲){1}+\d+$/', $message)) {
		// $info = explode('/', $message);
		$info = substr($message, 3);
		if($info>=$min_point && $info<=$xz_max['zx']){
			// $data['start'] = serialize(str_split($info));
			$data['points'] = $info;
			$data['type'] = 5;
		}else{
			if ($info<$min_point) {
				$data['error'] = 0;
			} else {
				$data['error'] = 2;
			}
			$data['xz_max'] = $xz_max['zx'];
		}
	}

	//冠亚号码(20-5,000)
	// 组/5-6/50 = 5号.6号车在冠亚军(顺序不限) = 总$50
	// 组/1-9.3-7/100 = 1.9号车或3.7号车在冠亚军(顺序不限) = 总$200
	if ($xz_open['gy'] && preg_match('/^组\/{1}+([0-9]{1}-[0-9]{1}\.)*([0-9]{1}-[0-9]{1})+\/{1}+\d+$/', $message)) {
		$info = explode('/', $message);
		if($info[2]>=$min_point && $info[2]<=$xz_max['gy']){
			if (strlen($info[1]) > 3) {
				$info2 = explode('.', $info[1]);
				for ($i = 0; $i < count($info2); $i++) {
					$info3[$i] = explode('-', $info2[$i]);
					if ($info3[$i][0] == $info3[$i][1]) {
						$res = 0;
						return false;
					} else {
						$res = 1;
					}
					for ($a = 0; $a < $i - 1; $a++) {
						if ($info2[$i] == $info2[$a]) {
							$res = 0;
							return false;
						} else {
							$res = 1;
						}
						$info3 = explode('-', $info2[$a]);
						$info4 = $info3[1] . '-' . $info3[0];
						if ($info2[$i] == $info4) {
							$res = 0;
							return false;
						} else {
							$res = 1;
						}
					}
				}
				if ($res == 1) {
					$data['start'] = serialize($info2);
					$data['points'] = $info[2]*count($info2);
					$data['type'] = 6;
				}
			} else {
				$info1 = explode('-', $info[1]);
				if ($info1[0] != $info1[1]) {
					$data['start'] = serialize(array('0' => $info[1]));
					$data['points'] = $info[2];
					$data['type'] = 6;
				}
			}
		}else{
			if ($info[2]<$min_point) {
				$data['error'] = 0;
			} else {
				$data['error'] = 2;
			}
			$data['xz_max'] = $xz_max['gy'];
		}	
	}

	//特码大小单双(20-20,000)
	// 和双100 = 「冠亚和」的双$100
	if ($xz_open['tema'] && preg_match('/^(和|特){1}(大|小|单|双){1}+\d+$/', $message)) {
		$info = substr($message, 6);
		if($info>=$min_point && $info<=$xz_max['tema']){
			$data['start'] = serialize(str_split($info[0]));
			$data['points'] = $info;
			$data['type'] = 7;
		}else{
			if ($info<$min_point) {
				$data['error'] = 0;
			} else {
				$data['error'] = 2;
			}
			$data['xz_max'] = $xz_max['tema'];
		}
	}

	//特码数字
	// 3.4.18.19，含本42倍，限额20-1,000
	// 5.6.16.17，含本21倍，限额20-2,000
	// 7.8.14.15，含本14倍，限额20-3,000
	// 9.10.12.13，含本10倍，限额20-4,000
	// 11，含本8倍，限额20-5,000
	// 和567/100 = 竞猜「冠亚和」的值为5或6或7各$100 = 总$300
	// 和341819/100
	if ($xz_open['tema_sz_1'] && preg_match('/^(和|特){1}(([3-9]{1}|1[0-9]{1}){1})*+\/{1}+\d+$/', $message)) {
		$info = explode('/', $message);

		$start = substr($info[0], 3);
		if($info[1]>=$min_point && $info[1]<=$xz_max['tema_sz']){
			$num_str = str_split($start);
			$info_str = array();
			for($a=0;$a<count($num_str);$a++){
				if ($a >= 1) {
					if ($num_str[$a-1] == '1') {
						if ( $num_str[$a-2] == '1' && $num_str[$a] == '1') {
							
						} else {
							continue;
						}
					}
				}
				if ($num_str[$a] == '1') {
					$info_str[] = $num_str[$a] . $num_str[$a+1];
				} else {
					$info_str[] = $num_str[$a];
				}
			}

			$data['points'] = $info[1]*count($info_str);
			$data['type'] = 8;

		}else{
			if ($info[1]<$min_point) {
				$data['error'] = 0;
			} else {
				$data['error'] = 2;
			}
			$data['xz_max'] = $xz_max['tema_sz'];
		}
	}

	//特码数字
	// 3.4.18.19，含本42倍，限额20-1,000
	// 5.6.16.17，含本21倍，限额20-2,000
	// 7.8.14.15，含本14倍，限额20-3,000
	// 9.10.12.13，含本10倍，限额20-4,000
	// 11，含本8倍，限额20-5,000
	// 和5.6.7/100 = 竞猜「冠亚和」的值为5或6或7各$100 = 总$300
	// 和3.4.18.19/100
	// if ($xz_open['tema_sz_1'] && preg_match('/^(和|特){1}(([3-9]|1[0-9]).)*([3-9]|1[0-9])+\/{1}+\d+$/', $message)) {
	// 	$info = explode('/', $message);
	// 	$start = substr($info[0], 3);
	// 	if($info[1]>=$min_point){
	// 		if (strlen($start) > 1) {
	// 			$res = explode('.', $start);
	// 			if (count($res) == count(array_unique($res))) {
	// 				$data['start'] = serialize(str_split(substr($info[0], 3)));
	// 				$data['points'] = $info[1]*count($res);
	// 				$data['type'] = 8;
	// 			}
	// 		} else {
	// 			$data['start'] = serialize(str_split(substr($info[0], 3)));
	// 			$data['points'] = $info[1];
	// 			$data['type'] = 8;
	// 		}
	// 	}else{
	// 		if ($info[1]<$min_point) {
	// 			$data['error'] = 0;
	// 		} else {
	// 			$data['error'] = 2;
	// 		}
	// 		$data['xz_max'] = $xz_max['tema_sz'];
	// 	}
	// }

	//特码区段(20-10,000)
	//BC/100 = 投注BC段位各100＝总$200
	if ($xz_open['tema_qd_1'] && preg_match('/^(A|B|C){1,4}+\/{1}+\d+$/', $message)) {
		$info = explode('/', $message);
		if($info[1]>=$min_point && $info[1]<=$xz_max['tema_qd']){
			$data['start'] = serialize(str_split($info[0]));
			$data['points'] = $info[1]*count(str_split($info[0]));
			$data['type'] = 9;
		}else{
			if ($info[1]<$min_point) {
				$data['error'] = 0;
			} else {
				$data['error'] = 2;
			}
			$data['xz_max'] = $xz_max['tema_qd'];
		}
	}
	return $data;
}

function check_format_ssc($message,$min_point,$max_point,$xz_open,$xz_max) {
	$data['error'] = 1;

	//定位球(20-20,000)
	// 12345/89/20 = 1~5求的开出8、9各买$20 = 总$200
	if ($xz_open['dwq'] && preg_match('/^(?!\d*?(\d)\d*?\1)[1-5]{1,5}+\/{1}+(?!\d*?(\d)\d*?\1)[0-9]{1,10}+\/{1}+\d+$/', $message)) {
		$info = explode('/', $message);
		if ($info[2] >= $min_point && $info[2] <= $xz_max['dwq']) {
			// $data['start'] = serialize(str_split($info[0]));
			$data['points'] = $info[2]*strlen($info[0])*strlen($info[1]);
			$data['type'] = 2;
		} else {
			if ($info[2]<$min_point) {
				$data['error'] = 0;
			} else {
				$data['error'] = 2;
			}
			$data['xz_max'] = $xz_max['dwq'];
		}
	}

	//单号 8/100  
	if ($xz_open['dh'] && preg_match('/^(1|2|3|4|5|6|7|8|9|0){1}+\/{1}+\d+$/', $message)) {
		$info = explode('/', $message);
		if ($info[1] >= $min_point && $info[1] <= $xz_max['dh']) {
			// $data['start'] = serialize(str_split($info[0]));
			$data['points'] = $info[1];
			$data['type'] = 9;
		} else {
			if ($info[1]<$min_point) {
				$data['error'] = 0;
			} else {
				$data['error'] = 2;
			}
			$data['xz_max'] = $xz_max['dh'];
		}
	}

	//连码  14/100  346/100   4567/100   12345/100
	if ($xz_open['lm'] && preg_match('/^(?!\d*?(\d)\d*?\1)[0-9]{2,5}+\/{1}+\d+$/', $message)) {
		$info = explode('/', $message);
		if ($info[1] >= $min_point && $info[1] <= $xz_max['lm']) {
			// $data['start'] = serialize(str_split($info[0]));
			$data['points'] = $info[1];
			$data['type'] = 10;
		} else {
			if ($info[1]<$min_point) {
				$data['error'] = 0;
			} else {
				$data['error'] = 2;
			}
			$data['xz_max'] = $xz_max['lm'];
		}
	}


	//龙虎和(20-20,000)
	if ($xz_open['lhh'] && preg_match('/^(龙|虎|合){1}+\d+$/', $message)) {
		$info = substr($message, 3);
		if ($info>=$min_point && $info<=$xz_max['lhh']) {
			// $data['start'] = serialize(str_split($info[0]));
			$data['points'] = $info;
			$data['type'] = 3;
		} else {
			if ($info<$min_point) {
				$data['error'] = 0;
			} else {
				$data['error'] = 2;
			}
			$data['xz_max'] = $xz_max['lhh'];
		}
	}

	//定位大小单双(20-20,000)
	// 12345/双/100 = 1~5车道买双各$100 = 总$500
	if ($xz_open['dxds'] && preg_match('/^(?!\d*?(\d)\d*?\1)[1-5]{1,5}+(大|双|小|单){1}+\d+$/', $message)) {
		$info = explode('/', $message);
		$ex_info = explode('大', $message);
		if (count($ex_info) > 1) {
			$info = $ex_info;
		}
		$ex_info = explode('小', $message);
		if (count($ex_info) > 1) {
			$info = $ex_info;
		}
		$ex_info = explode('单', $message);
		if (count($ex_info) > 1) {
			$info = $ex_info;
		}
		$ex_info = explode('双', $message);
		if (count($ex_info) > 1) {
			$info = $ex_info;
		}
		
		// $info = explode('/', $message);
		if($info[1]>=$min_point && $info[1]<=$xz_max['dxds']){
			$data['points'] = $info[1]*strlen($info[0]);
			$data['type'] = 1;
		}else{
			if ($info[1]<$min_point) {
				$data['error'] = 0;
			} else {
				$data['error'] = 2;
			}
			$data['xz_max'] = $xz_max['dxds'];
		}
	}

	// 中三大小   中三/大/100
	if ($xz_open['z3dx'] && preg_match('/^(中三){1}+\/{1}+(大|小|单|双){1}+\/{1}+\d+$/', $message)) {
		$info = explode('/', $message);
		if($info[2]>=$min_point && $info[2]<=$xz_max['z3dx']){
			// $data['start'] = serialize(str_split($info[0]));
			$data['points'] = $info[2];
			$data['type'] = 8;
		}else{
			if ($info[2]<$min_point) {
				$data['error'] = 0;
			} else {
				$data['error'] = 2;
			}
			$data['xz_max'] = $xz_max['z3dx'];
		}
	}



	//总大小单双
	if ($xz_open['zdxds'] && preg_match('/^(大|小|单|双|和){1}+\d+$/', $message)) {
		$info = substr($message, 3);
		if($info>=$min_point && $info<=$xz_max['zdxds']){
			// $data['start'] = serialize(str_split($info[0]));
			$data['points'] = $info;
			$data['type'] = 4;
		}else{
			if ($info<$min_point) {
				$data['error'] = 0;
			} else {
				$data['error'] = 2;
			}
			$data['xz_max'] = $xz_max['zdxds'];
		}
	}

	//总 大单 小双 小单 大双
	if ($xz_open['z_zuhe'] && preg_match('/^(大单|小双|小单|大双){1}+\d+$/', $message)) {
		$info = substr($message, 6);
		if($info>=$min_point && $info<=$xz_max['z_zuhe']){
			$data['points'] = $info;
			$data['type'] = 12;
		}else{
			if ($info<$min_point) {
				$data['error'] = 0;
			} else {
				$data['error'] = 2;
			}
			$data['xz_max'] = $xz_max['z_zuhe'];
		}
	}

	//前中后豹子顺子对子半顺杂六
	if ($xz_open['qzh'] && preg_match('/^(前|中|后){1}(豹子|顺子|对子|半顺|杂六){1}+\d+$/', $message)) {
		$info = substr($message, 9);
		if($info>=$min_point && $info<=$xz_max['qzh']){
			// $data['start'] = serialize(str_split($info[0]));
			$data['points'] = $info;
			$data['type'] = 5;
		}else{
			if ($info<$min_point) {
				$data['error'] = 0;
			} else {
				$data['error'] = 2;
			}
			$data['xz_max'] = $xz_max['qzh'];
		}
	}

	//特码区段(20-10,000)
	//BC/100 = 投注BC段位各100＝总$200
	if ($xz_open['tema_qd'] && preg_match('/^(A|B|C){1,3}+\/{1}+\d+$/', $message)) {
		$info = explode('/', $message);
		if($info[1]>=$min_point && $info[1]<=$xz_max['tema_qd']){
			// $data['start'] = serialize(str_split($info[0]));
			$data['points'] = $info[1]*count(str_split($info[0]));
			$data['type'] = 6;
		}else{
			if ($info[1]<$min_point) {
				$data['error'] = 0;
			} else {
				$data['error'] = 2;
			}
			$data['xz_max'] = $xz_max['tema_qd'];
		}
	}

	//二字定位 13/34.56/100
	if ($xz_open['he'] && preg_match('/^([1-5]{1}[1-5]{1})+\/{1}+([0-9]{1,10}\.[0-9]{1,10}){1}+\/{1}+\d+$/', $message)) {
		$info = explode('/', $message);
		$ws = explode('.', $info[1]);
		
		if($info[2]>=$min_point && $info[2]<=$xz_max['he']){
			$data['points'] = count(str_split($ws[0]))*count(str_split($ws[1]))*$info[2];
			$data['type'] = 7;
		}else{
			if ($info[2]<$min_point) {
				$data['error'] = 0;
			} else {
				$data['error'] = 2;
			}
			$data['xz_max'] = $xz_max['he'];
		}
	}

	//二字定位去重 13/34.56/100
	if ($xz_open['he_qc'] && preg_match('/^([1-5]{1}[1-5]{1})+\/{1}+([0-9]{1,10}\.[0-9]{1,10}){1}+\/{1}+\d+\/{1}+(去){1}+$/', $message)) {
		$info = explode('/', $message);
		$ws = explode('.', $info[1]);
		
		if($info[2]>=$min_point && $info[2]<=$xz_max['he']){
			$num9 = 0;
			foreach (str_split($ws[0]) as $k => $v) {
				foreach (str_split($ws[1]) as $m => $n) {
					if ($v == $n) {
						$num9++;
					}
				}
			}

			$data['points'] = (count(str_split($ws[0]))*count(str_split($ws[1]))-$num9)*$info[2];
			$data['type'] = 9;
		}else{
			if ($info[2]<$min_point) {
				$data['error'] = 0;
			} else {
				$data['error'] = 2;
			}
			$data['xz_max'] = $xz_max['he_qc'];
		}
	}
	return $data;
}

function check_format_bj28($message,$min_point,$max_point,$xz_open,$xz_max) {
	$data['error'] = 1;

	
	//大小单双  大100  小100
	if ($xz_open['dxds'] && preg_match('/^(大|小|单|双){1}+\d+$/', $message)) {
		$info = substr($message, 3);
		if($info>=$min_point && $info<=$xz_max['dxds']){
			$data['points'] = $info;
			$data['type'] = 1;
		}else{
			if ($info<$min_point) {
				$data['error'] = 0;
			} else {
				$data['error'] = 2;
			}
			$data['xz_max'] = $xz_max['dxds'];
		}
	}

	//组合(20-10,000)
	// 大单100 = 大单各买$100 
	if ($xz_open['zuhe_1'] && preg_match('/^(大单|小双|小单|大双){1}+\d+$/', $message)) {
		
		$info = substr($message, 6);
		if($info>=$min_point && $info<=$xz_max['zuhe']){
			$data['points'] = $info;
			$data['type'] = 2;
		}else{
			if ($info<$min_point) {
				$data['error'] = 0;
			} else {
				$data['error'] = 2;
			}
			$data['xz_max'] = $xz_max['zuhe'];
		}
	}

	// 极大100 
	if ($xz_open['jdx'] && preg_match('/^(极大|极小){1}+\d+$/', $message)) {
		$info = substr($message, 6);
		if($info>=$min_point && $info<=$xz_max['jdx']){
			$data['points'] = $info;
			$data['type'] = 3;
		}else{
			if ($info<$min_point) {
				$data['error'] = 0;
			} else {
				$data['error'] = 2;
			}
			$data['xz_max'] = $xz_max['jdx'];
		}
	}

	// 庄闲和  庄100 
	if ($xz_open['zx'] && preg_match('/^(庄|闲|和){1}+\d+$/', $message)) {
		$info = substr($message, 3);
		if($info>=$min_point && $info<=$xz_max['zx']){
			$data['points'] = $info;
			$data['type'] = 4;
		}else{
			if ($info<$min_point) {
				$data['error'] = 0;
			} else {
				$data['error'] = 2;
			}
			$data['xz_max'] = $xz_max['zx'];
		}
	}

	//豹子顺子对子   豹子100
	if ($xz_open['bds'] && preg_match('/^(豹子|顺子|对子|半顺|杂六){1}+\d+$/', $message)) {
		$info = substr($message, 6);
		if($info>=$min_point && $info<=$xz_max['bds']){
			$data['points'] = $info;
			$data['type'] = 5;
		}else{
			if ($info<$min_point) {
				$data['error'] = 0;
			} else {
				$data['error'] = 2;
			}
			$data['xz_max'] = $xz_max['bds'];
		}
	}

	
	// 0-27点100  ([3-9]{1}|1[0-9]{1}){1}
	if ($xz_open['tema'] && preg_match('/^(2[0-7]{1}|1[0-9]{1}|[0-9]{1}){1}+(点|.){1}+\d+$/', $message)) {
		// $info = explode('点', $message);
		$ex_info = explode('点', $message);
		if (count($ex_info) > 1) {
			$info = $ex_info;
		}

		$ex_info = explode('.', $message);
		if (count($ex_info) > 1) {
			$info = $ex_info;
		}



		if($info[1]>=$min_point && $info[1]<=$xz_max['tema']){
			$data['points'] = $info[1];
			$data['type'] = 6;
		}else{
			if ($info[1]<$min_point) {
				$data['error'] = 0;
			} else {
				$data['error'] = 2;
			}
			$data['xz_max'] = $xz_max['tema'];
		}
	}

	return $data;
}

function check_format_k3($message,$min_point,$max_point,$xz_open,$xz_max) {
	$data['error'] = 1;
	//大小单双  大100  小100
	if ($xz_open['dxds'] && preg_match('/^(大|小|单|双){1}+\d+$/', $message)) {
		$info = substr($message, 3);
		if($info>=$min_point && $info<=$xz_max['dxds']){
			$data['points'] = $info;
			$data['type'] = 1;
		}else{
			if ($info<$min_point) {
				$data['error'] = 0;
			} else {
				$data['error'] = 2;
			}
			$data['xz_max'] = $xz_max['dxds'];
		}
	}

	//单码   单码135/100
	if ($xz_open['dm'] && preg_match('/^(单码){1}([1-6]{1}){1,10}+\/{1}+\d+$/', $message)) {
		$info = explode('/', $message);
		$start = substr($info[0], 6);
		if($info[1]>=$min_point && $info[1]<=$xz_max['dm']){
			$starts = str_split($start);
			$data['points'] = $info[1] * count($starts);
			$data['type'] = 2;
		}else{
			if ($info[1]<$min_point) {
				$data['error'] = 0;
			} else {
				$data['error'] = 2;
			}
			$data['xz_max'] = $xz_max['dm'];
		}
	}

	//红号(112,113,114,115,116,122,223,224,225,226,133,233,334,335,336,144,244,344,445,446,155,255,355,455,556,166,266,366,466,566)   
	// 112/100
	if ($xz_open['honghao'] && preg_match('/^(112|113|114|115|116|122|223|224|225|226|133|233|334|335|336|144|244|344|445|446|155|255|355|455|556|166|266|366|466|566){1}+\/{1}+\d+$/', $message)) {
		$info = explode('/', $message);
		if($info[1]>=$min_point && $info[1]<=$xz_max['honghao']){
			$data['points'] = $info[1];
			$data['type'] = 3;
		}else{
			if ($info[1]<$min_point) {
				$data['error'] = 0;
			} else {
				$data['error'] = 2;
			}
			$data['xz_max'] = $xz_max['honghao'];
		}
	}

	//黑号(123,124,125,126,134,135,136,145,146,156,234,235,236,245,246,256,345,346,356,456)   
	// 112/100
	if ($xz_open['heihao'] && preg_match('/^(123|124|125|126|134|135|136|145|146|156|234|235|236|245|246|256|345|346|356|456){1}+\/{1}+\d+$/', $message)) {
		$info = explode('/', $message);
		if($info[1]>=$min_point && $info[1]<=$xz_max['heihao']){
			$data['points'] = $info[1];
			$data['type'] = 4;
		}else{
			if ($info[1]<$min_point) {
				$data['error'] = 0;
			} else {
				$data['error'] = 2;
			}
			$data['xz_max'] = $xz_max['heihao'];
		}
	}

	//硬连
	// 连112/100
	if ($xz_open['yinglian'] && preg_match('/^(连){1}[1-6]{1}[1-6]{1}[1-6]{1}+\/{1}+\d+$/', $message)) {
		$info = explode('/', $message);
		if($info[1]>=$min_point && $info[1]<=$xz_max['yinglian']){
			$data['points'] = $info[1];
			$data['type'] = 9;
		}else{
			if ($info[1]<$min_point) {
				$data['error'] = 0;
			} else {
				$data['error'] = 2;
			}
			$data['xz_max'] = $xz_max['yinglian'];
		}
	}

	

	//连
	// 连12/100
	if ($xz_open['lian'] && preg_match('/^(连){1}[1-6]{1}[1-6]{1}+\/{1}+\d+$/', $message)) {
		$info = explode('/', $message);
		if($info[1]>=$min_point && $info[1]<=$xz_max['lian']){
			$data['points'] = $info[1];
			$data['type'] = 12;
		}else{
			if ($info[1]<$min_point) {
				$data['error'] = 0;
			} else {
				$data['error'] = 2;
			}
			$data['xz_max'] = $xz_max['lian'];
		}
	}

	//豹子(111,222,333,444,555,666)   
	// 112/100
	if ($xz_open['baozi'] && preg_match('/^(111|222|333|444|555|666){1}+\/{1}+\d+$/', $message)) {
		$info = explode('/', $message);
		if($info[1]>=$min_point && $info[1]<=$xz_max['baozi']){
			$data['points'] = $info[1];
			$data['type'] = 5;
		}else{
			if ($info[1]<$min_point) {
				$data['error'] = 0;
			} else {
				$data['error'] = 2;
			}
			$data['xz_max'] = $xz_max['baozi'];
		}
	}

	//包豹子   
	// 包豹子100
	if ($xz_open['baobaozi'] && preg_match('/^(包豹子){1}+\d+$/', $message)) {
		$info = substr($message,9);
		if($info>=$min_point && $info<=$xz_max['baobaozi']){
			$data['points'] = $info;
			$data['type'] = 11;
		}else{
			if ($info<$min_point) {
				$data['error'] = 0;
			} else {
				$data['error'] = 2;
			}
			$data['xz_max'] = $xz_max['baobaozi'];
		}
	}

	//特码和值
	// 和3417/100
	if ($xz_open['tema'] && preg_match('/^(和){1}(([4-9]{1}|1[0-7]{1}){1})*+\/{1}+\d+$/', $message)) {
		$info = explode('/', $message);
		$start = substr($info[0], 3);
		if($info[1]>=$min_point && $info[1]<=$xz_max['tema']){
			$num_str = str_split($start);
			$info_str = array();
			for($a=0;$a<count($num_str);$a++){
				if ($a >= 1) {
					if ($num_str[$a-1] == '1') {
						if ( $num_str[$a-2] == '1' && $num_str[$a] == '1') {
							
						} else {
							continue;
						}
					}
				}
				if ($num_str[$a] == '1') {
					$info_str[] = $num_str[$a] . $num_str[$a+1];
				} else {
					$info_str[] = $num_str[$a];
				}
			}

			$data['points'] = $info[1]*count($info_str);
			$data['type'] = 6;

		}else{
			if ($info[1]<$min_point) {
				$data['error'] = 0;
			} else {
				$data['error'] = 2;
			}
			$data['xz_max'] = $xz_max['tema'];
		}
	}

	//另一种下注格式 和4.5.16.17/100
	// if ($xz_open['tema'] && preg_match('/^(和|特){1}(([4-9]|1[0-7]).)*([4-9]|1[0-7])+\/{1}+\d+$/', $message)) {
	// 	$info = explode('/', $message);
	// 	$start = substr($info[0], 3);
	// 	if($info[1]>=$min_point){
	// 		if (strlen($start) > 1) {
	// 			$res = explode('.', $start);
	// 			if (count($res) == count(array_unique($res))) {
	// 				$data['start'] = serialize(str_split(substr($info[0], 3)));
	// 				$data['points'] = $info[1]*count($res);
	// 				$data['type'] = 6;
	// 			}
	// 		} else {
	// 			$data['start'] = serialize(str_split(substr($info[0], 3)));
	// 			$data['points'] = $info[1];
	// 			$data['type'] = 6;
	// 		}
	// 	}else{
	// 		if ($info[1]<$min_point) {
	// 			$data['error'] = 0;
	// 		} else {
	// 			$data['error'] = 2;
	// 		}
	// 		$data['xz_max'] = $xz_max['tema'];
	// 	}
	// }



	//二不同(111,222,333,444,555,666)   
	// 112/100
	if ($xz_open['ebt'] && preg_match('/^(12|13|14|15|16|23|24|25|26|34|35|36|45|46|56){1}+\/{1}+\d+$/', $message)) {
		$info = explode('/', $message);
		if($info[1]>=$min_point && $info[1]<=$xz_max['dm']){
			$data['points'] = $info[1];
			$data['type'] = 7;
		}else{
			if ($info[1]<$min_point) {
				$data['error'] = 0;
			} else {
				$data['error'] = 2;
			}
			$data['xz_max'] = $xz_max['ebt'];
		}
	}

	//二相同(111,222,333,444,555,666)   
	// 112/100
	if ($xz_open['ext'] && preg_match('/^(11|22|33|44|55|66){1}+\/{1}+\d+$/', $message)) {
		$info = explode('/', $message);
		if($info[1]>=$min_point && $info[1]<=$xz_max['ext']){
			$data['points'] = $info[1];
			$data['type'] = 8;
		}else{
			if ($info[1]<$min_point) {
				$data['error'] = 0;
			} else {
				$data['error'] = 2;
			}
			$data['xz_max'] = $xz_max['ext'];
		}
	}
	return $data;
}

// 语言切换函数
function languageReplace($content, $type='en'){
    $path = './ascss/language/'.$type.'/';
    $files= scandir($path);
    $languages = [];
    foreach ($files as $vo){
        $file = $path . $vo;
        if(is_dir($file)) continue;
        $con = file_get_contents($file);
        $con = str_replace("\n", "###", $con);
        $con = explode("###", $con);
        $languages = array_merge(array_filter($con), $languages);
    }
    
    $preg = '/data-language="(.*?)"(.*?)>[\s\S]*?</';
    $replace = 'data-language="$1"$2>__$1__<';
    $content = preg_replace($preg, $replace, $content);
    // var_dump($content);exit();
    // 
    $preg = '/placeholder="(.*?)"/';
    $replace = 'placeholder="__$1__"';
    $content = preg_replace($preg, $replace, $content);
    
    // 语言替换
    foreach ($languages as $lang){
        $lang = str_replace(' = ', '=', $lang);
        $rep = explode("=", $lang);
        $content = str_replace('__'.$rep[0].'__', $rep[1], $content);
    }
    
    return $content;
}

?>